// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Graph
{
	public sealed partial class VertexDefinition
	{
		[JsonInclude]
		[JsonPropertyName("exclude")]
		public IEnumerable<string>? Exclude { get; set; }

		[JsonInclude]
		[JsonPropertyName("field")]
		public Elastic.Clients.Elasticsearch.Field Field { get; set; }

		[JsonInclude]
		[JsonPropertyName("include")]
		public IEnumerable<Elastic.Clients.Elasticsearch.Graph.VertexInclude>? Include { get; set; }

		[JsonInclude]
		[JsonPropertyName("min_doc_count")]
		public long? MinDocCount { get; set; }

		[JsonInclude]
		[JsonPropertyName("shard_min_doc_count")]
		public long? ShardMinDocCount { get; set; }

		[JsonInclude]
		[JsonPropertyName("size")]
		public int? Size { get; set; }
	}

	public sealed partial class VertexDefinitionDescriptor<TDocument> : SerializableDescriptorBase<VertexDefinitionDescriptor<TDocument>>
	{
		internal VertexDefinitionDescriptor(Action<VertexDefinitionDescriptor<TDocument>> configure) => configure.Invoke(this);
		public VertexDefinitionDescriptor() : base()
		{
		}

		private IEnumerable<string>? ExcludeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }

		private IEnumerable<Elastic.Clients.Elasticsearch.Graph.VertexInclude>? IncludeValue { get; set; }

		private VertexIncludeDescriptor IncludeDescriptor { get; set; }

		private Action<VertexIncludeDescriptor> IncludeDescriptorAction { get; set; }

		private Action<VertexIncludeDescriptor>[] IncludeDescriptorActions { get; set; }

		private long? MinDocCountValue { get; set; }

		private long? ShardMinDocCountValue { get; set; }

		private int? SizeValue { get; set; }

		public VertexDefinitionDescriptor<TDocument> Exclude(IEnumerable<string>? exclude)
		{
			ExcludeValue = exclude;
			return Self;
		}

		public VertexDefinitionDescriptor<TDocument> Field(Elastic.Clients.Elasticsearch.Field field)
		{
			FieldValue = field;
			return Self;
		}

		public VertexDefinitionDescriptor<TDocument> Field<TValue>(Expression<Func<TDocument, TValue>> field)
		{
			FieldValue = field;
			return Self;
		}

		public VertexDefinitionDescriptor<TDocument> Include(IEnumerable<Elastic.Clients.Elasticsearch.Graph.VertexInclude>? include)
		{
			IncludeDescriptor = null;
			IncludeDescriptorAction = null;
			IncludeDescriptorActions = null;
			IncludeValue = include;
			return Self;
		}

		public VertexDefinitionDescriptor<TDocument> Include(VertexIncludeDescriptor descriptor)
		{
			IncludeValue = null;
			IncludeDescriptorAction = null;
			IncludeDescriptorActions = null;
			IncludeDescriptor = descriptor;
			return Self;
		}

		public VertexDefinitionDescriptor<TDocument> Include(Action<VertexIncludeDescriptor> configure)
		{
			IncludeValue = null;
			IncludeDescriptor = null;
			IncludeDescriptorActions = null;
			IncludeDescriptorAction = configure;
			return Self;
		}

		public VertexDefinitionDescriptor<TDocument> Include(params Action<VertexIncludeDescriptor>[] configure)
		{
			IncludeValue = null;
			IncludeDescriptor = null;
			IncludeDescriptorAction = null;
			IncludeDescriptorActions = configure;
			return Self;
		}

		public VertexDefinitionDescriptor<TDocument> MinDocCount(long? minDocCount)
		{
			MinDocCountValue = minDocCount;
			return Self;
		}

		public VertexDefinitionDescriptor<TDocument> ShardMinDocCount(long? shardMinDocCount)
		{
			ShardMinDocCountValue = shardMinDocCount;
			return Self;
		}

		public VertexDefinitionDescriptor<TDocument> Size(int? size)
		{
			SizeValue = size;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (ExcludeValue is not null)
			{
				writer.WritePropertyName("exclude");
				JsonSerializer.Serialize(writer, ExcludeValue, options);
			}

			writer.WritePropertyName("field");
			JsonSerializer.Serialize(writer, FieldValue, options);
			if (IncludeDescriptor is not null)
			{
				writer.WritePropertyName("include");
				writer.WriteStartArray();
				JsonSerializer.Serialize(writer, IncludeDescriptor, options);
				writer.WriteEndArray();
			}
			else if (IncludeDescriptorAction is not null)
			{
				writer.WritePropertyName("include");
				writer.WriteStartArray();
				JsonSerializer.Serialize(writer, new VertexIncludeDescriptor(IncludeDescriptorAction), options);
				writer.WriteEndArray();
			}
			else if (IncludeDescriptorActions is not null)
			{
				writer.WritePropertyName("include");
				writer.WriteStartArray();
				foreach (var action in IncludeDescriptorActions)
				{
					JsonSerializer.Serialize(writer, new VertexIncludeDescriptor(action), options);
				}

				writer.WriteEndArray();
			}
			else if (IncludeValue is not null)
			{
				writer.WritePropertyName("include");
				JsonSerializer.Serialize(writer, IncludeValue, options);
			}

			if (MinDocCountValue.HasValue)
			{
				writer.WritePropertyName("min_doc_count");
				writer.WriteNumberValue(MinDocCountValue.Value);
			}

			if (ShardMinDocCountValue.HasValue)
			{
				writer.WritePropertyName("shard_min_doc_count");
				writer.WriteNumberValue(ShardMinDocCountValue.Value);
			}

			if (SizeValue.HasValue)
			{
				writer.WritePropertyName("size");
				writer.WriteNumberValue(SizeValue.Value);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class VertexDefinitionDescriptor : SerializableDescriptorBase<VertexDefinitionDescriptor>
	{
		internal VertexDefinitionDescriptor(Action<VertexDefinitionDescriptor> configure) => configure.Invoke(this);
		public VertexDefinitionDescriptor() : base()
		{
		}

		private IEnumerable<string>? ExcludeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }

		private IEnumerable<Elastic.Clients.Elasticsearch.Graph.VertexInclude>? IncludeValue { get; set; }

		private VertexIncludeDescriptor IncludeDescriptor { get; set; }

		private Action<VertexIncludeDescriptor> IncludeDescriptorAction { get; set; }

		private Action<VertexIncludeDescriptor>[] IncludeDescriptorActions { get; set; }

		private long? MinDocCountValue { get; set; }

		private long? ShardMinDocCountValue { get; set; }

		private int? SizeValue { get; set; }

		public VertexDefinitionDescriptor Exclude(IEnumerable<string>? exclude)
		{
			ExcludeValue = exclude;
			return Self;
		}

		public VertexDefinitionDescriptor Field(Elastic.Clients.Elasticsearch.Field field)
		{
			FieldValue = field;
			return Self;
		}

		public VertexDefinitionDescriptor Field<TDocument, TValue>(Expression<Func<TDocument, TValue>> field)
		{
			FieldValue = field;
			return Self;
		}

		public VertexDefinitionDescriptor Field<TDocument>(Expression<Func<TDocument, object>> field)
		{
			FieldValue = field;
			return Self;
		}

		public VertexDefinitionDescriptor Include(IEnumerable<Elastic.Clients.Elasticsearch.Graph.VertexInclude>? include)
		{
			IncludeDescriptor = null;
			IncludeDescriptorAction = null;
			IncludeDescriptorActions = null;
			IncludeValue = include;
			return Self;
		}

		public VertexDefinitionDescriptor Include(VertexIncludeDescriptor descriptor)
		{
			IncludeValue = null;
			IncludeDescriptorAction = null;
			IncludeDescriptorActions = null;
			IncludeDescriptor = descriptor;
			return Self;
		}

		public VertexDefinitionDescriptor Include(Action<VertexIncludeDescriptor> configure)
		{
			IncludeValue = null;
			IncludeDescriptor = null;
			IncludeDescriptorActions = null;
			IncludeDescriptorAction = configure;
			return Self;
		}

		public VertexDefinitionDescriptor Include(params Action<VertexIncludeDescriptor>[] configure)
		{
			IncludeValue = null;
			IncludeDescriptor = null;
			IncludeDescriptorAction = null;
			IncludeDescriptorActions = configure;
			return Self;
		}

		public VertexDefinitionDescriptor MinDocCount(long? minDocCount)
		{
			MinDocCountValue = minDocCount;
			return Self;
		}

		public VertexDefinitionDescriptor ShardMinDocCount(long? shardMinDocCount)
		{
			ShardMinDocCountValue = shardMinDocCount;
			return Self;
		}

		public VertexDefinitionDescriptor Size(int? size)
		{
			SizeValue = size;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (ExcludeValue is not null)
			{
				writer.WritePropertyName("exclude");
				JsonSerializer.Serialize(writer, ExcludeValue, options);
			}

			writer.WritePropertyName("field");
			JsonSerializer.Serialize(writer, FieldValue, options);
			if (IncludeDescriptor is not null)
			{
				writer.WritePropertyName("include");
				writer.WriteStartArray();
				JsonSerializer.Serialize(writer, IncludeDescriptor, options);
				writer.WriteEndArray();
			}
			else if (IncludeDescriptorAction is not null)
			{
				writer.WritePropertyName("include");
				writer.WriteStartArray();
				JsonSerializer.Serialize(writer, new VertexIncludeDescriptor(IncludeDescriptorAction), options);
				writer.WriteEndArray();
			}
			else if (IncludeDescriptorActions is not null)
			{
				writer.WritePropertyName("include");
				writer.WriteStartArray();
				foreach (var action in IncludeDescriptorActions)
				{
					JsonSerializer.Serialize(writer, new VertexIncludeDescriptor(action), options);
				}

				writer.WriteEndArray();
			}
			else if (IncludeValue is not null)
			{
				writer.WritePropertyName("include");
				JsonSerializer.Serialize(writer, IncludeValue, options);
			}

			if (MinDocCountValue.HasValue)
			{
				writer.WritePropertyName("min_doc_count");
				writer.WriteNumberValue(MinDocCountValue.Value);
			}

			if (ShardMinDocCountValue.HasValue)
			{
				writer.WritePropertyName("shard_min_doc_count");
				writer.WriteNumberValue(ShardMinDocCountValue.Value);
			}

			if (SizeValue.HasValue)
			{
				writer.WritePropertyName("size");
				writer.WriteNumberValue(SizeValue.Value);
			}

			writer.WriteEndObject();
		}
	}
}